package com.bian.springboot.mapper;

import com.bian.springboot.entities.Department;
import org.apache.ibatis.annotations.*;

/**
 * @author bianpengfei
 * @create 2019-02-01 19:04
 **/

// 指定这是一个操作数据的mapper
@Mapper
public interface DepartmentMapper {

    @Select("select * from department where id=#{id}")
    Department getDeptId(Integer id);

    @Delete("delete from department where id=#{id}")
    int deleteDepteById(Integer id);

    // option 中的userGeneratedKeys keyProperty 可以返回id
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into department (departmentName) values (#{departmentName})")
    int addDept(Department department);

    @Update("update department set departmentName=#{departmentName} where id = #{id}")
    int modifyDept(Department department);
}
